<template>
	<view class="mainpadding2">
		<view class="flexbetween flex_wrap">
			<view class="tehui margin_top" v-for="item in list.data" :key="item.id" style="height: auto;"
				@click="jumpurl('/pages/index/detail?id=',item.cj.id)">
				<view class="tehui" style="width: 100%;">
					<image :src="item.cj.image_text" class="tehuiimage" mode=""></image>
					<view class="fuwulable" v-if="item.cj.is_th">特惠</view>
					<view class="rightidnum xiaobai">ID：{{item.cj.id}}</view>
				</view>
				<view class="yihang main_size hei_text margin_top1">{{item.cj.name}}</view>
				<view class="xiaohuang yihang margin_top1" v-if="!is_login" @click.stop="gologin">查看报价</view>
				<view class="xiaohuang yihang margin_top1" v-if="is_login">{{item.cj.price}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				is_login:false
			}
		},
		onShow() {
			this.init()
			this.is_login = httpRequest.checkIsLogin();
		},
		onShareAppMessage: function(options) {
			return {
				title: '制片宝',
				imageUrl: '',
				path: '/pages/index/index'
			}
		},
		onShareTimeline: function() {
			return {
				title: '制片宝',
				imageUrl: '',
				path: '/pages/index/index'
			}
		},
		methods: {
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
				}
				httpRequest.request('user/cjCollectIndex', 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			gologin(){				uni.navigateTo({					url:"/pages/login/login"				})			},
			jumpurl(url,id){
				uni.navigateTo({
					url:url+id
				})
			},
		}
	}
</script>

<style>

</style>
